<?php
namespace Home\Controller;
use Admin\Model\MatchModel;
use Admin\Model\StyleModel;
use Common\Model\CommonModel;
use Think\Controller;

class DesignerController extends Controller{


    public function index(){

        //区域
        $areaModel=M('area');
        $arrArea=$areaModel->select();
        $this->assign('arrArea',$arrArea);
        //var_dump($arrArea);exit;
        //风格
        $styleModel=new StyleModel();
        $arrStyle=$styleModel->select();
        $this->assign('arrStyle',$arrStyle);
        //($arrStyle);exit;
        //设计师
        $designerModel=M('designer');
        $count = $designerModel->count();
        $page= new \Think\Page($count,9);
        $page->setConfig('next','下一页');
        $page->setConfig('prev','上一页');
        //显示还有多少条
        $page->setConfig('theme','%HEADER% %FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END%');
        $show = $page->show();
        $arrDesigner=$designerModel->limit($page->firstRow.','.$page->listRows)->select();
        $arrDesigner=CommonModel::photo1($arrDesigner);
        $arrDesigner=$styleModel->getStyle($arrDesigner);
        //var_dump($arrDesigner);exit;
        $this->assign('arrDesigner',$arrDesigner);
        $this->assign('page',$show);
        $this->display();

    }

    public function match(){
        $data['city']='上海';
        $data['area_id']=htmlspecialchars($_POST['area_id']);
        $data['plot']=htmlspecialchars($_POST['plot']);
        $data['place']=htmlspecialchars($_POST['place']);
        $data['style_id']=htmlspecialchars($_POST['style_id']);
        $data['butget']=htmlspecialchars($_POST['butget']);
        $data['remark']=htmlspecialchars($_POST['remark']);
        $data['create']=time();
        $matchModel=new MatchModel();

        $res=$matchModel->add($data);

        if($res){
            echo 1; exit;
        }else{
            echo 2; exit;
        }


    }

    public function order(){

        $IndexController= new IndexController();
        $IndexController->order();

    }


}